﻿-- Author  : Kurapica
-- Create Date : 2009/10/12

--[[
	In-Game Addon System
	Studio Part		
	Frame Layout for Studio
--]]
do
	IGAS:NewAddon("IGAS_Studio")
	
	-- BackDrop for frames
	local _FrameBackdrop = {
		bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
		edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
		tile = true, tileSize = 16, edgeSize = 16,
		insets = { left = 3, right = 3, top = 3, bottom = 3 }
	}
	
	-- menu
	local menu = CreateFrame(Widget.MenuStrip, "Menu", coreF)	
	menu:SetPoint("TOPLEFT", coreF, "TOPLEFT")
	menu:SetPoint("TOPRIGHT", coreF, "TOPRIGHT")
	menu.Height = 30
	
	-- WidgetPanel
	local widgetPanel = CreateFrame(Widget.WidgetList, "WidgetPanel", coreF)
	widgetPanel:SetPoint("TOPLEFT", menu, "BOTTOMLEFT")
	widgetPanel:SetPoint("BOTTOMLEFT", coreF, "BOTTOMLEFT")
	widgetPanel:SetMinResize(100,widgetPanel.Height)
	widgetPanel:SetMaxResize(300,widgetPanel.Height)
	widgetPanel.Width = 200
	
	-- FileView
	local fileView = CreateFrame("Frame", "FileView", coreF)
	fileView:SetPoint("TOPRIGHT", menu, "BOTTOMRIGHT")
	fileView.Height = 400
	fileView.Width = 200
	fileView:SetMinResize(100,200)
	fileView:SetMaxResize(300,600)
	
	-- PropertyPanel
	local propertyPanel = CreateFrame(Widget.PropertyList, "PropertyPanel", coreF)
	propertyPanel:SetPoint("TOPLEFT", fileView, "BOTTOMLEFT", 0, -5)
	propertyPanel:SetPoint("TOPRIGHT", fileView, "BOTTOMRIGHT", 0, -5)
	propertyPanel:SetPoint("BOTTOMRIGHT", coreF, "BOTTOMRIGHT")
	
	-- DesignPanel
	local designPanel = CreateFrame("TabGroup", "DesignPanel", coreF)
	designPanel:SetPoint("TOP", menu, "BOTTOM")
	designPanel:SetPoint("BOTTOM", coreF, "BOTTOM")
	designPanel:SetPoint("LEFT", widgetPanel, "RIGHT", 5, 0)
	designPanel:SetPoint("RIGHT", fileView, "LEFT", -5, 0)
	
	-- Seperates
	local spWD = CreateFrame("Frame", "SpW2D", coreF)
	spWD.MouseEnabled = true
	spWD:SetPoint("TOPLEFT", widgetPanel, "TOPRIGHT")
	spWD:SetPoint("BOTTOMLEFT", widgetPanel, "BOTTOMRIGHT")
	spWD:SetPoint("TOPRIGHT", designPanel, "TOPLEFT")
	spWD:SetPoint("BOTTOMRIGHT", designPanel, "BOTTOMLEFT")	
	local highLight = CreateFrame("Texture", "HighLight", spWD, "BACKGROUND")
	highLight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
	highLight:SetBlendMode("ADD")
	highLight:SetAllPoints(spWD)
	highLight.Visible = false	
	
	local spFP = CreateFrame("Frame", "SpF2P", coreF)
	spFP.MouseEnabled = true
	spFP:SetPoint("TOPLEFT", fileView, "BOTTOMLEFT")
	spFP:SetPoint("TOPRIGHT", fileView, "BOTTOMRIGHT")
	spFP:SetPoint("BOTTOMLEFT", propertyPanel, "TOPLEFT")
	spFP:SetPoint("BOTTOMRIGHT", propertyPanel, "TOPRIGHT")
	highLight = CreateFrame("Texture", "HighLight", spFP, "BACKGROUND")
	highLight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
	highLight:SetBlendMode("ADD")
	highLight:SetAllPoints(spFP)
	highLight.Visible = false
	
	local spFD = CreateFrame("Frame", "SpF2D", coreF)
	spFD.MouseEnabled = true
	spFD:SetPoint("TOPRIGHT", fileView, "TOPLEFT")
	spFD:SetPoint("TOPLEFT", designPanel, "TOPRIGHT")
	spFD:SetPoint("BOTTOM", coreF, "BOTTOM")
	highLight = CreateFrame("Texture", "HighLight", spFD, "BACKGROUND")
	highLight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
	highLight:SetBlendMode("ADD")
	highLight:SetAllPoints(spFD)
	highLight.Visible = false
	
	-- Scripts
	local OnEnter = function(self)
		self:GetChild("HighLight").Visible = true
	end
	local OnLeave = function(self)
		self:GetChild("HighLight").Visible = false
	end
	spWD.OnEnter = OnEnter
	spFP.OnEnter = OnEnter
	spFD.OnEnter = OnEnter
	spWD.OnLeave = OnLeave
	spFP.OnLeave = OnLeave
	spFD.OnLeave = OnLeave
	
	spWD.OnMouseDown = function(self)
		widgetPanel:StartSizing("RIGHT")
	end	
	spWD.OnMouseUp = function(self)
		widgetPanel:StopMovingOrSizing()
		widgetPanel:SetPoint("TOPLEFT", menu, "BOTTOMLEFT")
		widgetPanel:SetPoint("BOTTOMLEFT", coreF, "BOTTOMLEFT")
	end
	
	spFP.OnMouseDown = function(self)
		fileView:StartSizing("BOTTOM")
	end	
	spFP.OnMouseUp = function(self)
		fileView:StopMovingOrSizing()
		fileView:SetPoint("TOPRIGHT", menu, "BOTTOMRIGHT")
	end
	
	spFD.OnMouseDown = function(self)
		fileView:StartSizing("LEFT")
	end	
	spFD.OnMouseUp = function(self)
		fileView:StopMovingOrSizing()
		fileView:SetPoint("TOPRIGHT", menu, "BOTTOMRIGHT")
	end
end
